Fix soundness issues#74
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
- Coverage 99.53% 99.40% -0.13%
==========================================
Files 7 7
Lines 639 668 +29
==========================================
+ Hits 636 664 +28
- Misses 3 4 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Contributor
Author
|
I believe you are correct - |
Member
|
Thanks, these fixes seem valid. I'll get them deployed ASAP! |
This was referenced May 7, 2026
shssoichiro
pushed a commit
that referenced
this pull request
May 8, 2026
These should not have been public in the first place. This makes invalid state between geometry and data impossible (fixing any problems related to #61) and results in a nicer API overall. Basically: Plane and AlignedData have safety invariants that depend on the state of PlaneGeometry when `Plane::new` is called. By both validating the geometry in its constructor and making it fully immutable, we ensure that the invariants are always fulfilled. This also means we can remove the re-validation of geometry (part of #74) from `Plane::new`. Changes: - add getters - make getters return zeroable scalars over NonZero<T>. With `#[inline]` this should elide unnecessary `width != 0` checks downstream while making the API simpler (`plane.width().get()` -> `plane.width()`) - move data_origin from Plane to geometry, not something downstream needs without padding awareness (-> `-F padding_api`)
shssoichiro
pushed a commit
that referenced
this pull request
May 8, 2026
#74 uncovered that empty data/len==0 returned a dangling pointer that was not following the same alignment as real allocations. This required some doc changes and is just not nice in general. Use `layout.dangling_ptr` instead of the less specific `NonNull::dangling_ptr` to follow our "usual" alignment rules exactly. This requires an MSRV bump to 1.95.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first commit adds tests that demonstrate undefined behavior in safe code under
miri.The second commit fixes the issues with minimal API changes. The API could be adjusted to make such issues less likely (e.g. pre-validated fields should not be public and mutable), but this PR only provides a semver-compatible fix.
The third commit updates documentation to more clearly communicate alignment requirements to API users.
Impact analysis
The alignment issue is mostly theoretical and should not impact real-world uses.
The missing field validation results in buffer overflow, but you need to edit the fields after the initial validation pass; I don't expect this to be common in the wild (albeit I haven't verified that), so I don't think it warrants a full-on security advisory, but you might want to get an unsoundness advisory into RustSec with the
informational = unsoundfield.